home *** CD-ROM | disk | FTP | other *** search
- property userName, firstChannel, locH, locV, letterHoffsets, firstLetterBmap, levelBmapChannel, cursor, levelLocH, levelLocV, savedGameList, nameString, maxChars, onOrOff, cursorCounter, maxWidth, cursorSpeed, maxCharWidth, oldUserGameNum
- global gLevelObject, gMenuObject, gHelpObject
-
- on birth me
- set firstChannel to 26
- set locH to 147
- set locV to 211
- set levelBmapChannel to 25
- set levelLocH to 450
- set levelLocV to 60
- set maxChars to 11
- set maxCharWidth to 18
- set userName to []
- set letterHoffsets to [0]
- set firstLetterBmap to the number of cast "a.lower"
- set cursor to firstLetterBmap + 53
- set savedGameList to []
- set nameString to EMPTY
- set oldUserGameNum to 0
- set onOrOff to 0
- set cursorCounter to 1
- set cursorSpeed to 6
- set maxWidth to 156
- return me
- end
-
- on update me
- if count(userName) = 0 then
- blinkQuestion(me)
- end if
- end
-
- on keyHandler me
- set whichKey to the key
- set ascii to charToNum(whichKey)
- if (ascii >= 65) and (ascii <= 90) then
- enterLetter(me, whichKey, ascii - 64)
- else
- if (ascii >= 97) and (ascii <= 122) then
- enterLetter(me, whichKey, ascii - 96)
- else
- if ascii = 8 then
- eraseLetter(me)
- else
- if ascii = 45 then
- enterLetter(me, whichKey, 53)
- end if
- end if
- end if
- end if
- end
-
- on charToBitmap me, keyString
- set ascii to charToNum(keyString)
- if (ascii >= 97) and (ascii <= 122) then
- set castPos to ascii - 96
- else
- if (ascii >= 65) and (ascii <= 90) then
- set castPos to ascii - 38
- else
- if ascii = 45 then
- set castPos to 53
- end if
- end if
- end if
- return castPos
- end
-
- on setDefaultUserName me
- set nameList to ["Crusher", "Big-Shot", "Dozer", "Digger"]
- set defaultName to getAt(nameList, random(count(nameList)))
- repeat with x = 1 to the number of chars in defaultName
- set letter to char x of defaultName
- set letterNum to charToBitmap(me, letter)
- set whichCast to firstLetterBmap + letterNum - 1
- set letterWidth to getKernValue(whichCast)
- set currentOffset to getLast(letterHoffsets)
- add(userName, letterNum)
- add(letterHoffsets, currentOffset + letterWidth)
- end repeat
- set the saveEnabled of gMenuObject to 0
- end
-
- on enterLetter me, whichKey, letterNum
- if ((getLast(letterHoffsets) + maxCharWidth) <= maxWidth) and (count(userName) < maxChars) then
- set channel to firstChannel + count(userName)
- if count(userName) = 0 then
- if letterNum = 53 then
- exit
- end if
- set letterNum to letterNum + 26
- end if
- set whichCast to firstLetterBmap + letterNum - 1
- set letterWidth to getKernValue(whichCast)
- set the castNum of sprite channel to whichCast
- set currentOffset to getLast(letterHoffsets)
- set the locH of sprite channel to locH + currentOffset
- set the locV of sprite channel to locV
- updateStage()
- add(userName, letterNum)
- add(letterHoffsets, currentOffset + letterWidth)
- set nameString to nameString & whichKey
- else
- beep(1)
- end if
- end
-
- on eraseLetter me
- if count(userName) > 0 then
- deleteAt(userName, count(userName))
- deleteAt(letterHoffsets, count(letterHoffsets))
- set the locH of sprite (firstChannel + count(userName)) to 1000
- updateStage()
- set nameLength to length(nameString)
- if nameLength > 1 then
- set nameString to char 1 to nameLength - 1 of nameString
- else
- set nameString to EMPTY
- end if
- else
- beep(1)
- end if
- end
-
- on blinkQuestion me
- if cursorCounter > cursorSpeed then
- if onOrOff = 0 then
- set the locH of sprite firstChannel to locH
- set the locV of sprite firstChannel to locV
- set the castNum of sprite firstChannel to cursor
- set onOrOff to 1
- else
- set the locH of sprite firstChannel to 1000
- set onOrOff to 0
- end if
- set cursorCounter to 0
- else
- set cursorCounter to cursorCounter + 1
- end if
- end
-
- on fillName me
- drawUserName(me, firstChannel, locH, locV)
- end
-
- on drawUserName me, channelNum, Xloc, Yloc
- repeat with x = 1 to count(userName)
- set channel to firstChannel + x - 1
- puppetSprite(channel, 1)
- set the castNum of sprite channel to firstLetterBmap + getAt(userName, x) - 1
- set the locH of sprite channel to Xloc + getAt(letterHoffsets, x)
- set the locV of sprite channel to Yloc
- end repeat
- repeat with x = count(userName) + 1 to maxChars
- set channel to firstChannel + x - 1
- set the locH of sprite channel to 1000
- puppetSprite(channel, 0)
- end repeat
- end
-
- on addPeriod me
- set periodSprite to firstChannel + count(userName)
- set the castNum of sprite periodSprite to firstLetterBmap + 54
- set the locH of sprite periodSprite to the nameX of gMenuObject + getLast(letterHoffsets)
- set the locV of sprite periodSprite to the nameY of gMenuObject
- puppetSprite(periodSprite, 1)
- end
-
- on drawUserLevel me
- set the castNum of sprite levelBmapChannel to getAt(the bmapList of gLevelObject, the level of gLevelObject)
- set the locH of sprite levelBmapChannel to levelLocH
- set the locV of sprite levelBmapChannel to levelLocV
- puppetSprite(levelBmapChannel, 1)
- end
-
- on unpuppetUserData me
- repeat with x = 1 to count(userName) + 1
- set channel to firstChannel + x - 1
- puppetSprite(channel, 0)
- end repeat
- puppetSprite(levelBmapChannel, 0)
- end
-
- on puppetUserData me
- repeat with x = 1 to count(userName)
- set channel to firstChannel + x - 1
- puppetSprite(channel, 1)
- end repeat
- puppetSprite(levelBmapChannel, 1)
- end
-
- on puppetAllUserSprites me
- repeat with x = 1 to 12
- set channel to firstChannel + x - 1
- puppetSprite(channel, 1)
- end repeat
- end
-
- on saveUserData me
- set userDataString to string(the quitEnabled of gMenuObject) & ","
- set userDataString to userDataString & string(the printEnabled of gMenuObject) & ","
- set userDataString to userDataString & nameString & ","
- repeat with x in userName
- set userDataString to userDataString & string(x) & ","
- end repeat
- repeat with x = 2 to count(letterHoffsets)
- set userDataString to userDataString & string(getAt(letterHoffsets, x)) & ","
- end repeat
- return userDataString
- end
-
- on loadUserData me, index
- set the quitEnabled of gMenuObject to value(item index of the dataString of gMenuObject)
- set index to index + 1
- set the printEnabled of gMenuObject to value(item index of the dataString of gMenuObject)
- set index to index + 1
- set nameString to item index of the dataString of gMenuObject
- set letterQuantity to length(nameString)
- set userName to []
- set letterHoffsets to [0]
- repeat with x = 1 to letterQuantity
- add(userName, value(item index + x of the dataString of gMenuObject))
- end repeat
- repeat with x = 1 to letterQuantity
- add(letterHoffsets, value(item index + letterQuantity + x of the dataString of gMenuObject))
- end repeat
- return index + (letterQuantity * 2) + 1
- end
-
- on help me, buttonObject
- birth(script "Help Parent", buttonObject, #LogIn)
- end
-